<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta name="keywords"
    content="HTML,CSS,HTML5,CSS3,ES6,JavaScript,Vue,Vue.js,TS,TypeScript,webpack,node.js,git,npm,前端,全栈,Web开发" />
  <meta name="description" content="一位Web开发工程师的学习、工作笔记-星之痕。
    内容涵盖：HTML,CSS,HTML5,CSS3,ES6,JavaScript,Vue,Vue.js,TS,TypeScript,前端,全栈,Web开发……等" />
  <title>Vue.js 笔记-星之痕</title>
  <link rel="stylesheet" href="./css/global.css">
</head>

<body>
  <div id="app">

    <div>
      <h2>{{title}}</h2>
      <ul>
        <li v-for='msg in messages'>{{msg}}</li>
      </ul>
    </div>
    <button v-on:click='action'>点击</button>

  </div>

  <script src="js/vue.js"></script>
  <script>
    Vue.config.productionTip = false; //阻止vue页面在启动时的生产提示

    const app = new Vue({
      // el: '#app',
      data: {
        title: 'this is a title',
        messages: [
          'this is a vue demo!',
        ]
      },
      computed: {

      },
      methods: {
        action() {
          this.title = 'hello!';
        }
      }
    });

    // 调用Vue Prototype上原有$methods 方法的方式
    app.$mount('#app');

    // 在Vue原型上挂载方法
    app.prototype = {}
    app.prototype.logstr = function () {
      console.log('this is a method of vue.prototype');
    }
    // console.log(app);

    // 调用Vue prototype原型上自己挂载的方法的方式
    app.prototype.logstr()
  </script>
</body>

</html>
